import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/src/widgets/framework.dart';

import '../../net/post_request.dart';
import '../../net/response/food/order_model_list_data.dart';

class SelectOrderTypeViewModel extends BaseListViewModel<OrderModelListData>{
  SelectOrderTypeViewModel(BuildContext context) : super(context);

  @override
  Future<List<OrderModelListData>> requestListData() async {
    var data = await PostRequest.getOrderModel(1, 20);
    if('0'==data['code'].toString()){
      var list = ((data['data']['rows'] as List?)??[])
          .map((e) => OrderModelListData.fromJson(e))
          .toList();
      var items =  list.where((element) => element.name=="周点餐").toList();
      return list;
    }else{
      throw data['msg'];
    }
  }

  @override
  void onCreated() {
    super.onCreated();
    requestRefresh();
  }

}